<template>
  <div id="main">
    <nav class="navbar">
      <el-scrollbar style="height: 100%; width: 221px">
        <!-- 头像栏 -->
        <div class="nav-header">
          <div class="profile-element">
            <div class="user-box">
              <img class="user-img" src="@/assets/images/app/avatar.png" />
              <div class="user-tip">
                <p class="user-name">管理员</p>
                <p class="user-type">默认角色</p>
              </div>
            </div>
          </div>
        </div>
        <!-- 菜单栏 -->
        <el-menu
          background-color="#1e282c"
          text-color="#a7b1c2"
          active-text-color="#fff"
          :default-openeds="['1', '3']"
        >
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-message"></i>演示模块</template>
            <el-menu-item index="1-1">
              <router-link to="/workman/im">语音生成工具(websocket)</router-link>
            </el-menu-item>
            <el-menu-item index="1-2">
              <router-link to="/redis/rr">redis及rabbitmq</router-link>
            </el-menu-item>
            <!-- <el-menu-item index="1-3">echarts</el-menu-item>
            <el-menu-item index="1-4">excel pdf</el-menu-item> -->
          </el-submenu>
          <!-- <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>导航二</template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
            <el-menu-item index="2-3">选项3</el-menu-item>
            <el-menu-item index="2-4">选项4</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"
              ><i class="el-icon-setting"></i>导航三</template
            >
            <el-menu-item index="3-1">选项1</el-menu-item>
            <el-menu-item index="3-2">选项2</el-menu-item>
            <el-menu-item index="3-3">选项3</el-menu-item>
            <el-menu-item index="3-4">选项4</el-menu-item>
          </el-submenu> -->
        </el-menu>
      </el-scrollbar>
    </nav>
    <div id="page-wrapper">
      <el-scrollbar style="height: 100%; width: 100%">
        <!-- 显示菜单栏 -->
        <div id="main-header">
          <!-- @tab-remove="removeTab" -->
          <!-- <el-tabs
            class="page-tabs"
            type="card"
            closable
          >
            <el-tab-pane key="1" label="导航栏1" name="导航栏1"> </el-tab-pane>
            <el-tab-pane key="2" label="导航栏2" name="导航栏2"> </el-tab-pane>
            <el-tab-pane key="3" label="导航栏3" name="导航栏3"> </el-tab-pane>
          </el-tabs> -->
          <div class="login-out" title="退出" @click="LoginOut">
            <i class="fa fa-sign-out"></i>
          </div>
        </div>
        <!-- 主要显示栏目 -->
        <router-view id="content-main">

        </router-view>
      </el-scrollbar>
    </div>
  </div>
</template>

<style scoped lang="less">
html,
body {
  position: absolute;
}

#main {
  position: absolute;
  width: 100%;
  height: 100%;
  min-width: 1200px;
  min-height: 800px;
  overflow: hidden;
}

.navbar {
  position: relative;
  width: 220px;
  height: 100%;
  z-index: 1;
  background-color: #1e282c;

  .profile-element {
    height: 156px;
    width: 100%;
    background: url("@/assets/images/app/header-profile.png") no-repeat;
    padding: 20px;

    .user-box {
      height: 120px;
      width: 80px;
      margin: 10px auto 0 auto;

      .user-img {
        margin-left: 8px;
        height: 64px;
        width: 64px;
        border-radius: 5px;
        cursor: pointer;
      }

      .user-tip {
        text-align: center;
        .user-name {
          color: white;
          font-weight: bold;
          letter-spacing: 1px;
          margin-top: 5px;
        }
        .user-type {
          margin-top: 1px;
          color: #8095a8;
          font-size: 12px;
        }
      }
    }
  }

  .el-menu-item {
    position: relative;

    a {
      position: absolute;
      width: 100%;
      height: 100%;
      transform: translateX(-40px);
      padding-left: 40px;
    }

    a,
    a:visited,
    a:hover,
    a:active,
    a:link {
      text-decoration: none;
      color: rgb(167, 177, 194);
    }
  }
}

#page-wrapper {
  position: absolute;
  padding-left: 220px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;

  #main-header {
    position: absolute;
    top: 0;
    width: 100%;
    height: 50px;
    padding-right: 50px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
  }

  #content-main {
    padding-top: 50px;
    position: absolute;
    height: 100%;
    width: 100%;
    overflow: auto;
  }

  .el-tabs__header {
    margin: 0;
  }

  .login-out {
    height: 50px;
    width: 50px;
    background-color: white;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
    border-left: 1px solid rgba(0, 0, 0, 0.05);

    &:hover {
      color: #333;
      background-color: rgba(0, 0, 0, 0.1);
    }

    i {
      font-size: 16px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%,-50%);
    }
  }
}
</style>

<style lang="less">
#main {
  .el-scrollbar__wrap {
    overflow-x: hidden !important;
  }
  .el-submenu__title {
    height: 40px;
    line-height: 40px;
  }
  .el-menu-item {
    height: 32px;
    line-height: 32px;
  }
  .el-tabs__header {
    margin: 0;
  }
  .el-tabs__item {
    padding-top: 5px;
    height: 50px;
  }
}
</style>

<script>
import { clearUserInfo } from '@/utils/storage'
export default {
  name: 'OaMain',
  mounted () {
  },
  methods: {
    LoginOut () {
      this.$confirm('是否退出登录?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        clearUserInfo()
        this.$router.push('/login')
      })
    }
  }
}
</script>
